#!/usr/bin/env bash

help(){
    cat<<__EOF__
Usage: m display [OPTIONS]

Description: Manage display settings on macOS

Options:
  --help     Show this help message
  --status   Show current display status
  --up       Increase display brightness
  --down     Decrease display brightness

__EOF__
}

display_status(){
    system_profiler SPDisplaysDataType
}

turn_up(){
    osascript -e 'tell application "System Events"' -e 'key code 144' -e ' end tell'
}

turn_down(){
    osascript -e 'tell application "System Events"' -e 'key code 145' -e ' end tell'
}

case $1 in
    --help)
        help
        ;;
    --status)
        display_status
        ;;
    --up)
        turn_up
        ;;
    --down)
        turn_down
        ;;
    *)
        help && exit 1
        ;;
esac
